<%@ page language="java"  pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.sh169.util.ApplicationUtil"%><html>
<head>
	<title>Threads in oschina</title>
	<style>
	body {font-size:8pt;}
	ol {line-height:18px;}
	</style>
	</head>
	<body>
	<strong>request attribute</strong>
	<ul>
		<li><%=request.getRemoteAddr() %></li>
		<li><%=request.getRemoteHost() %></li>
		<li><%=request.getRemoteUser() %></li>
		<li><%=request.getRemotePort() %></li>
		<li><%=request.getLocalAddr() %></li>
		<li><%=request.getLocalName() %></li>
	</ul>
	<strong>java.io.tmpdir:</strong>
	<ul>
	<li><%=System.getProperty("java.io.tmpdir")%></li>
	</ul>
	<strong>tomcat root</strong>
	<ul>
	<li><%=ApplicationUtil.getWebHomePath()%></li>
	</ul>
	<br/>
	<strong>Memory:</strong>
	<ol>
	<li>freeMemory=<%=Runtime.getRuntime().freeMemory()/(1024*1024)%>M</li>
	    <li>totalMemory=<%=Runtime.getRuntime().totalMemory()/(1024*1024)%>M</li>
	    <li>maxMemory=<%=Runtime.getRuntime().maxMemory()/(1024*1024)%>M</li>
	</ol>
	<br/>
	<strong>Thread:</strong>
	<ol>
	<%for(Thread t : list_threads()){%>
	<li><%=t.getName()%>(<b><%=t.getState()%></b>) : <%=t.getClass().getName()%></li>
	<%}%>
	</ol>
	<%!
	public static java.util.List<Thread> list_threads(){
	    int tc = Thread.activeCount();
	    Thread[] ts = new Thread[tc];
	    Thread.enumerate(ts);
	    return java.util.Arrays.asList(ts);
	}
	%>
	</body>
	</html>